﻿using SixLabors.ImageSharp;
using Yolov8Net;

namespace project.B12.Service
{
    public class Detector
    {
        private readonly YoloV8Predictor _yolo;
        private IPredictor yolov8;

        public Detector()
        {
            string onnxPath= Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "best.onnx");
            string[] labels = new string[] { "bubble", "centralBacteria" };
            yolov8 = YoloV8Predictor.Create(onnxPath, labels);
        }

        public Prediction[] Detect(string imgPath)
        {
            using var image = Image.Load(imgPath);
            var result = yolov8.Predict(image);
            return result;
        }
    }
}
